package github.kawaiior.yuanchuxiuzhen.common.entity.addon;

import github.kawaiior.yuanchuxiuzhen.common.entity.ILevelEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

public class BoneWolfEntity extends MonsterEntity implements ILevelEntity {

    public static final EntityType<BoneWolfEntity> TYPE = EntityType.Builder
            .<BoneWolfEntity>create(BoneWolfEntity::new, EntityClassification.MONSTER)
            .size(1.2F, 1.0F).build("bone_wolf");

    protected BoneWolfEntity(EntityType<? extends MonsterEntity> type, World worldIn) {
        super(type, worldIn);
        this.applyEntityAI();
    }

    protected void applyEntityAI() {
        this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.0D, false));
        this.goalSelector.addGoal(5, new MoveTowardsRestrictionGoal(this, 1.0D));
        this.goalSelector.addGoal(7, new WaterAvoidingRandomWalkingGoal(this, 1.0D, 0.0F));
        this.goalSelector.addGoal(1, new LookAtGoal(this, PlayerEntity.class, 8.0F));
        this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
        this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setCallsForHelp());
        this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
    }

    @Override
    public int getLevel() {
        return 3;
    }
}
